<template>
	<view class="page">
		<!-- 用户信息 -->
		<view class="user-info">
			<view class="user-header">
				<view class="avatar-container">
					<image class="avatar" src="/static/images/avatar/default-avatar.png" mode="aspectFill"></image>
				</view>
				<view class="user-detail">
					<view class="username">Daisy</view>
					<view class="bind-phone">
						绑定手机 <text class="iconfont icon-right">></text>
					</view>
				</view>
				<view class="notification">
					<image class="notification-icon" src="/static/svg/notification.svg" mode="aspectFit"></image>
					<text class="badge">2</text>
				</view>
			</view>
			<view class="user-stats">
				<view class="stat-item" @click="navigateTo('/pages/my/favorite')">
					<text class="stat-num">12</text>
					<text class="stat-label">收藏</text>
				</view>
				<view class="stat-item" @click="navigateTo('/pages/my/footprint')">
					<text class="stat-num">34</text>
					<text class="stat-label">足迹</text>
				</view>
				<view class="stat-item" @click="navigateTo('/pages/my/coupon')">
					<text class="stat-num">5</text>
					<text class="stat-label">优惠券</text>
				</view>
			</view>
		</view>

		<!-- 我的订单 -->
		<view class="card order-card">
			<view class="card-header">
				<text class="title">我的订单</text>
				<view class="view-all" @click="navigateToOrder()">
					查看全部 <text class="iconfont icon-right">></text>
				</view>
			</view>
			<view class="order-actions">
				<view class="action-item" @click="navigateToOrder(0)">
					<image class="icon" src="/static/svg/wait-pay.svg" mode="aspectFit"></image>
					<text class="label">待付款</text>
				</view>
				<view class="action-item" @click="navigateToOrder(1)">
					<image class="icon" src="/static/svg/wait-share.svg" mode="aspectFit"></image>
					<text class="label">待分享</text>
				</view>
				<view class="action-item" @click="navigateToOrder(2)">
					<image class="icon" src="/static/svg/wait-ship.svg" mode="aspectFit"></image>
					<text class="label">待发货</text>
				</view>
				<view class="action-item" @click="navigateToOrder(3)">
					<image class="icon" src="/static/svg/wait-receive.svg" mode="aspectFit"></image>
					<text class="label">待收货</text>
				</view>
				<view class="action-item" @click="navigateToOrder(4)">
					<image class="icon" src="/static/svg/wait-comment.svg" mode="aspectFit"></image>
					<text class="label">待评价</text>
				</view>
			</view>
		</view>

		<!-- 必备工具 -->
		<view class="card tools-card">
			<view class="card-header">
				<text class="title">必备工具</text>
			</view>
			<view class="tools-grid">
				<view class="tool-item" @click="navigateTo('/pages/my/comment')">
					<image class="icon" src="/static/svg/my-comment.svg" mode="aspectFit"></image>
					<text class="label">我的评价</text>
				</view>
				<view class="tool-item" @click="navigateTo('/pages/my/address/index')">
					<image class="icon" src="/static/svg/address.svg" mode="aspectFit"></image>
					<text class="label">收货地址</text>
				</view>
				<view class="tool-item" @click="navigateTo('/pages/coupon/index')">
					<image class="icon" src="/static/svg/coupon.svg" mode="aspectFit"></image>
					<text class="label">领券中心</text>
				</view>
				<view class="tool-item" @click="navigateTo('/pages/my/service')">
					<image class="icon" src="/static/svg/refund.svg" mode="aspectFit"></image>
					<text class="label">退款售后</text>
				</view>
				<view class="tool-item">
					<image class="icon" src="/static/svg/service.svg" mode="aspectFit"></image>
					<text class="label">客服</text>
				</view>
				<view class="tool-item" @click="navigateTo('/pages/my/setting/index')">
					<image class="icon" src="/static/svg/settings.svg" mode="aspectFit"></image>
					<text class="label">设置</text>
				</view>
			</view>
		</view>

     <recommend-area></recommend-area>
	</view>
</template>

<script setup>
import { onLoad } from '@dcloudio/uni-app'
import RecommendArea from "../index/components/RecommendArea.vue";

onLoad(() => {
	console.log('个人中心页面加载')
})

// 页面通用跳转
const navigateTo = (url) => {
  uni.navigateTo({
    url: url
  });
}

// 订单页面导航
const navigateToOrder = (status) => {
  // 构建跳转URL，如果传递了status参数则带上该参数
  const url = status !== undefined ? `/pages/my/order/index?status=${status}` : '/pages/my/order/index';
  uni.navigateTo({
    url: url
  });
}
</script>

<style>
.page {
	background-color: #f8f8f8;
	min-height: 100vh;
	padding-bottom: 20rpx;
}

/* 用户信息区域 */
.user-info {
	background-color: #ffffff;
	padding: 30rpx;
	margin-bottom: 20rpx;
}

.user-header {
	display: flex;
	align-items: center;
	margin-bottom: 40rpx;
}

.avatar-container {
	position: relative;
	margin-right: 20rpx;
}

.avatar {
	width: 120rpx;
	height: 120rpx;
	border-radius: 50%;
}

.user-detail {
	flex: 1;
}

.username {
	font-size: 36rpx;
	font-weight: bold;
	margin-bottom: 10rpx;
}

.bind-phone {
	font-size: 26rpx;
	color: #666;
	display: flex;
	align-items: center;
}

.icon-right {
	font-size: 22rpx;
	margin-left: 4rpx;
}

.notification {
	position: relative;
}

.notification-icon {
	width: 50rpx;
	height: 50rpx;
}

.badge {
	position: absolute;
	top: -10rpx;
	right: -10rpx;
	background-color: #ff0000;
	color: #fff;
	font-size: 20rpx;
	width: 32rpx;
	height: 32rpx;
	border-radius: 50%;
	display: flex;
	justify-content: center;
	align-items: center;
}

.user-stats {
	display: flex;
	justify-content: space-around;
	padding: 20rpx 0;
}

.stat-item {
	display: flex;
	flex-direction: column;
	align-items: center;
}

.stat-num {
	font-size: 40rpx;
	color: #FF6E31;
	font-weight: bold;
	margin-bottom: 6rpx;
}

.stat-label {
	font-size: 26rpx;
	color: #666;
}

/* 卡片通用样式 */
.card {
	background-color: #ffffff;
	border-radius: 16rpx;
	margin: 20rpx;
	box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.05);
}

.card-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 20rpx 30rpx;
	border-bottom: 1rpx solid #f2f2f2;
}

.title {
	font-size: 30rpx;
	font-weight: bold;
}

.view-all {
	font-size: 26rpx;
	color: #999;
}

/* 订单区域 */
.order-actions {
	display: flex;
	justify-content: space-around;
	padding: 30rpx 0;
}

.action-item {
	display: flex;
	flex-direction: column;
	align-items: center;
}

.icon {
	width: 60rpx;
	height: 60rpx;
	margin-bottom: 10rpx;
}

.label {
	font-size: 24rpx;
	color: #333;
}

/* 工具区域 */
.tools-grid {
	display: flex;
	flex-wrap: wrap;
	padding: 10rpx 0;
}

.tool-item {
	width: 33.33%;
	display: flex;
	flex-direction: column;
	align-items: center;
	padding: 30rpx 0;
}

/* 推荐区域 */
.recommendations {
	padding: 0 20rpx;
}

.section-title {
	font-size: 32rpx;
	font-weight: bold;
	margin: 30rpx 0;
}
</style>
